package com.eudon.design_pattern.structural.proxy.static_proxy;

import com.eudon.design_pattern.structural.proxy.OrderCache;
import com.eudon.design_pattern.structural.proxy.Request;
import com.eudon.design_pattern.structural.proxy.UserController;

import java.util.List;

/**
 * @author eudon
 * @description 用户查询代理类，用户拦截请求判断是否需要查询缓存
 * @date 2025/9/1
 * @email syd19970616@gmail.com
 * @address <a href="https://gitee.com/eudon">Gitee</a>
 */
public class UserControllerCacheProxy extends UserController {
    public List<String> queryOrder(Request request){
        if (request.needCache()){
            System.out.println("检测到需要查询缓存，进行缓存查询");
            return OrderCache.getCache(request.userId());
        }
        return super.queryOrder(request);
    }
}
